<?php

namespace Library;

use Library\Traits\HasInstance;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger as MonologLogger;

/**
 * @method static Logger make(string $channel = "logger", string $level = "debug")
 */
class Logger extends MonologLogger
{

    private static ?Logger $instance = null;
    protected MonologLogger $logger;

    use HasInstance;

    /**
     * @param string $channel
     * @param string $level
     */
    public function __construct(string $channel = "logger", string $level = "debug")
    {
        $fileName = date("Y-m-d").".log";
        $logFile = LOW_CODE_STORAGE_PATH.DS."log".DS.$fileName;
        $handler = new StreamHandler($logFile, Level::fromName($level));
        parent::__construct($channel,[$handler]);
    }

    /**
     * @return MonologLogger
     */
    public function logger(): MonologLogger
    {
        return $this->logger;
    }

    public function __clone(): void
    {
        // TODO: Implement __clone() method.
    }
}